package at.fhooe.tof.mockup;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TOFMockupEventSource {
	  private List<ITOFMockupListener> _listeners = new ArrayList<ITOFMockupListener>();
	  
	  public synchronized void addEventListener(ITOFMockupListener listener)  {
	    _listeners.add(listener);
	  }
	  
	  public synchronized void removeEventListener(ITOFMockupListener listener)   {
	    _listeners.remove(listener);
	  }
	 
	  public synchronized void fireEvent() {
	    TOFMockupEvent event = new TOFMockupEvent(this);
	    Iterator<ITOFMockupListener> i = _listeners.iterator();
	    while(i.hasNext())  {
	      ((ITOFMockupListener) i.next()).handleTOFMockupEvent(event);
	    }
	  }
}
